package com.shopping.config;

import com.shopping.interceptor.ShoppingLoginINterceptor;
import com.shopping.interceptor.SystemLoginInterceptor;
import com.shopping.util.Page;
import com.shopping.util.SYS;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class ShoppingWebMVCConfig  implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //定义D://easyupload中的资源访问路径
        //让springmvc添加应该处理器，访问静态资源
        //浏览器访问 easyfile/文件名字  就访问到这个资源处理器
        registry.addResourceHandler(SYS.FILE_UPLOAD_URL+"/**").addResourceLocations("file:"+SYS.FILE_UPLOAD_DIR);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ShoppingLoginINterceptor()).addPathPatterns("/page/cart","/page/index","/cart/**","/page/profile","/page/order","/page/orderConfirm","/page/detail","/page/list");
        registry.addInterceptor(new SystemLoginInterceptor()).addPathPatterns("/system/index","/system/product","/system/category","/system/echarts","/system/order","/system/user","system/admin");
    }
}
